home *** CD-ROM | disk | FTP | other *** search
- Path: s20.phxslip4.indirect.com!pronet01
- From: pronet01@indirect.com (Mark Miller)
- Newsgroups: comp.lang.c
- Subject: Re: What does the -O option do???!!!
- Date: Mon, 5 Feb 1996 19:31:15 UNDEFINED
- Organization: Promark One
- Message-ID: <pronet01.34.003B9BB5@indirect.com>
- References: <4ehger$cj9@mark.ucdavis.edu> <4emlsq$odt@airdmhor.gen.nz>
- NNTP-Posting-Host: s20.phxslip4.indirect.com
- X-Newsreader: Trumpet for Windows [Version 1.0 Rev B final beta #1]
-
- In article <4emlsq$odt@airdmhor.gen.nz> gumboot@airdmhor.gen.nz (Simon Hosie) writes:
- >From: gumboot@airdmhor.gen.nz (Simon Hosie)
- >Subject: Re: What does the -O option do???!!!
- >Date: 31 Jan 1996 15:58:34 +1300
-
- >Ricardo E Espinoza-Ibarra:
-
- >> Does anyone know what the -O option in gcc C compiler does? I have tried
- >> to compile a program in two different ways: 1) cc -o first first.c, and it
- >> worksfine; 2) cc -o first first.c -O, and it runs faster than the other one.
- >> I checked to see if it had changed the program code in anyway, and it
- >> hadn't. This option stands for "optimizer", but I want to know how the heck
- >> it optimizes the program!
-
- > Perhaps if the second time you ran it you used "cc -o second first.c -O"
- >and then "cmp first second" rather than using "cc -o first fisrt.c -O" and
- >then "cmp first first"
-
- It definitely is the optimizing compiler flag...
-
- Warning: if you DO use the "-O" make sure you know of the caveats
- with certain compilers... Older versions of gcc/g++ did "evil" things
- to code compiled with "-O"... The compiler attempts to do double
- checks and reorganization of object code...
-
- Hint: When you're done using a pointer (and it has not gone out of
- scope), explicitly set it to NULL.. I have seen the optimized version
- move addresses for a pointer variable that you have used "free" on..
-
-
-